-
Notifications
You must be signed in to change notification settings - Fork 889
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cargo-fmt: remove command line validation which did not properly handle the windows environment #3309
Conversation
Haven’t tested it yet, but have skimmed the diff, and I’m >98% sure this won’t fix the problem, as it looks to only affect which arguments are slurped, which is not where the problem is (e.g. “package `member` is not a member of the workspace” indicates that it successfully slurped the package name, but that its workspace member list was awry). |
@chris-morgan on windows I suspect it's because we call |
Actually could you try removing |
I'm using the setup from #2694 on Windows 10. On branch scampi:issue2694:
On branch scampi:issue2694 and with skip(1) removed:
|
I added some
Here the result:
The result of Edit: Changing |
Thanks @jakoschiko for the help. You're right, canonicalize on Windows returns an extended-length path which adds the leading Regarding Lines 55 to 66 in 2a76d95
|
The following error was also reported
@jakoschiko Could you also provide a debug of the following line ? thanks Line 296 in 2a76d95
|
…leading "\\?\" which needs to be taken into account apply @jakoschiko fix
Using stable:
Using your current branch with the
|
…when called with 'cargo fmt'
@jakoschiko I reverted the change to I tried the changes locally and used the following debugs in the gif below. I didn't manage to reproduce @chris-morgan 's error:
I think this PR is fine now. @@ -54,7 +54,7 @@ fn execute() -> i32 {
// If there is any invalid argument passed to `cargo fmt`, return without formatting.
let mut is_package_arg = false;
- for arg in env::args().skip(1).take_while(|a| a != "--") {
+ for arg in dbg!(env::args()).skip(2).take_while(|a| a != "--") {
if arg.starts_with('-') {
is_package_arg = arg.starts_with("--package") | arg.starts_with("-p");
} else if !is_package_arg {
@@ -224,7 +224,7 @@ fn get_targets(strategy: &CargoFmtStrategy) -> Result<HashSet<Target>, io::Error
CargoFmtStrategy::Some(ref hitlist) => get_targets_with_hitlist(hitlist, &mut targets)?,
}
- if targets.is_empty() {
+ if dbg!(&targets).is_empty() {
Err(io::Error::new(
io::ErrorKind::Other,
"Failed to find targets".to_owned(),
@@ -292,10 +292,10 @@ fn get_targets_with_hitlist(
) -> Result<(), io::Error> {
let metadata = get_cargo_metadata(None)?;
- let mut workspace_hitlist: HashSet<&String> = HashSet::from_iter(hitlist);
+ let mut workspace_hitlist: HashSet<&String> = HashSet::from_iter(dbg!(hitlist));
for package in metadata.packages {
- if workspace_hitlist.remove(&package.name) {
+ if workspace_hitlist.remove(dbg!(&package.name)) {
for target in package.targets {
targets.insert(Target::from_target(&target));
} |
@jakoschiko @chris-morgan Could you give this branch a try ?
Maybe the problem in windows comes from our handling of
env::args()
, where the first item is skipped. That is usually the executable name, but not always:Close #2694